package com.siren.tank.group.bad;

import com.siren.tank.Audio;
import com.siren.tank.GameModel;
import com.siren.tank.ResourceMgr;
import com.siren.tank.group.Explode;

import java.awt.*;

/**
 * @author : wangjichao
 * @description:
 * @date : 2020/7/29 10:33
 */
public class BadExplode extends Explode {
    public static int WIDTH = ResourceMgr.explodes[0].getWidth();
    public static int HEIGHT = ResourceMgr.explodes[0].getHeight();

    private int x, y;
    private boolean live = true;

    private GameModel gm;

    private int step = 0;

    public boolean isLive() {
        return live;
    }

    public void setLive(boolean live) {
        this.live = live;
    }

    public BadExplode(int x, int y, GameModel gm) {
        super();
        this.x = x;
        this.y = y;
        this.gm = gm;
        new Thread(()->new Audio("audio/explode.wav").play()).start();
    }

    @Override
    public void paint(Graphics g) {
        Color c = g.getColor();
        g.setColor(Color.YELLOW);
        g.fillRect(x, y, 20 + 5*step, 20 + 5*step);
        step++;
        if (step >= 3) {
            gm.remove(this);
        }
    }
}
